﻿namespace NorthernLights.Controls
{
    using System.Windows;
    using System.Windows.Controls;

    /// <summary>
    /// Represents a message-box like control for getting user input.
    /// </summary>
    /// <remarks>
    /// http://blogs.microsoft.co.il/blogs/tomershamam/archive/2010/10/19/windows-phone-7-custom-message-box.aspx
    /// http://wpassets.codeplex.com/SourceControl/list/changesets
    /// </remarks>
    public class InputBox : ItemsControl
    {
        #region Fields
        /// <summary>
        /// Identifies the Title dependency property
        /// </summary>
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register(
            "Title",
            typeof(string),
            typeof(InputBox),
              new PropertyMetadata(default(string)));

        /// <summary>
        /// Identifies the Message dependency property.
        /// </summary>
        public static readonly DependencyProperty MessageProperty =
            DependencyProperty.Register(
            "Message",
            typeof(string),
            typeof(InputBox),
              new PropertyMetadata(default(string)));

        /// <summary>
        /// Identifies the Input dependency property.
        /// </summary>
        public static readonly DependencyProperty InputProperty = 
            DependencyProperty.Register(
            "Input", 
            typeof(string), 
            typeof(InputBox),
             new PropertyMetadata(default(string)));
        #endregion

        #region Constructor
        /// <summary>
        /// Initializes a new instance of the InputBox class.
        /// </summary>
        public InputBox()
        {
            DefaultStyleKey = typeof(NotificationBox);
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the title text to display.
        /// </summary>
        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        /// <summary>
        /// Gets or sets the message text to display.
        /// </summary>
        public string Message
        {
            get { return (string)GetValue(MessageProperty); }
            set { SetValue(MessageProperty, value); }
        }

        /// <summary>
        /// Gets or sets the input.
        /// </summary>
        public string Input
        {
            get { return (string)GetValue(InputProperty); }
            set { SetValue(InputProperty, value); }
        }
        #endregion

        #region Public methods
        /// <summary>
        /// Get container for item override.
        /// </summary>
        /// <returns>Returns a new notification box item.</returns>
        protected override DependencyObject GetContainerForItemOverride()
        {
            return new NotificationBoxItem();
        }

        /// <summary>
        /// Get if item is container is override.
        /// </summary>
        /// <param name="item">The object to check.</param>
        /// <returns>True if item is NotificationBoxItem.</returns>
        protected override bool IsItemItsOwnContainerOverride(object item)
        {
            return item is NotificationBoxItem;
        }
        #endregion
    }
}